<template>
    <div id="app" class="app">
    <el-row>
      <el-col :span="4" >
        <span class="app_title">管理后台</span>
        <el-menu :default-active="activeLink" :collapse="isCollapse" @select="handleSelect" class="sub-menu">
          <el-menu-item index="/home">
          <i class="el-icon-setting"></i>
          <span slot="title">首页</span>
          </el-menu-item>
          <el-submenu index="system">
            <template slot="title">
            <i class="el-icon-message"></i>
            <span slot="title">系统管理</span>
            </template>
              <el-menu-item index="/account">账户管理</el-menu-item>
              <el-menu-item index="/menu">菜单管理</el-menu-item>
          </el-submenu>
          <el-menu-item index="/application">
          <i class="el-icon-menu"></i>
          <span slot="title">应用管理</span>
          </el-menu-item>
        </el-menu>
      </el-col>
      <el-col :span="20">
        <div class="head">
          <el-menu theme="dark" mode="horizontal" class= "head_nav" @select="push">
            <el-submenu index="1">
              <template slot="title"><i class="el-icon-message"></i>消息</template>
                <el-menu-item index="/application">消息1</el-menu-item>
                <el-menu-item index="/application">消息2</el-menu-item>
            </el-submenu>
            <el-submenu index="2">
              <template slot="title"><i class=""></i>admin</template>
                <el-menu-item index="2-1" @click.native="destroy">退出</el-menu-item>
            </el-submenu>
          </el-menu>
        </div>
        <router-view class="app-view"></router-view>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: 'app',
  data() {
     return {
        isCollapse: false
     };
  },
  computed: {
    activeLink() {
        let link = '/' + this.$route.path.split('/')[1];
        return link
    }
  },
  methods: {
    handleSelect(key, keyPath) {
        console.log(key, keyPath);
        this.$router.push(key);
    },
    destroy() {
        this.$confirm('确认删除?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          console.log('退出')
        })
    },
    push(key, keyPath) {
      this.$router.push(key);
    }
  }
}
</script>

<style>
body{
    margin: 0;
}
.app_title {
    display: inline-block;
    padding: 0 20px;
    height: 60px;
    line-height: 60px;
    color: #324157;
    font-size: 22px;
    font-weight: 700;
}

.head {
    display: flex;
    justify-content: flex-end;
    background-color: #324157;
}
.sub-menu {
    height: calc(100vh - 60px);
    background-color: #eef1f6;
}
.app-view {
    padding: 15px;
}
</style>
